package com.itheima.health.controller.mobile;

import com.itheima.health.constant.MessageConstant;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController("mobileSetmealController")
@RequestMapping("/setmeal")
public class SetmealController {
    @Resource
    private SetmealService setmealService;

    /**
     * 获取所有套餐的信息
     */
    @RequestMapping("/getSetmeal.do")
    public Result getSetmeal() {
        List<Setmeal> list = setmealService.findAll();
        return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS, list);
    }

    @PostMapping("findFullSetmealById.do")
    public Result findFullSetmealById(Integer id) {
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmealService.findFullSetmealById(id));
    }

    @PostMapping("findById.do")
    public Result findById(Integer id){
        return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmealService.findById(id));
    }
}